home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Extra 1996 #3 / AmigaPlus_CD-ROM-EXTRA_Nr.3.bin / aminet-spiele / zwei spieler / stratego / strategodocs < prev    next >
Text File  |  1994-08-21  |  21KB  |  444 lines

  1.                         Serial Stratego Version 1.5
  2.  
  3.                         Written By: Daniel Oberlin
  4.  
  5.  
  6.  
  7.  
  8. I. INTRODUCTION
  9.  
  10. Serial Stratego is a program I wrote which allows Stratego to be played on two 
  11. computers linked by a serial connection.  The game Stratego is a strategic 
  12. board game marketed by Milton Bradley.  In this implementation, a serial 
  13. connection can be made by null-modem (direct serial connection), modem, or by 
  14. logging onto a networked computer and using UNIX or INTERNET resources such as 
  15. Talk, Write, or even IRC (Internet Relay Chat).  The program communicates by 
  16. sending packets which are encoded using standard printable ASCII characters 
  17. (like uuencode, see technical section for more information).  It filters out 
  18. all other characters, including anything which is not found between the start 
  19. and stop character which define the packet.  This makes it possible to employ 
  20. resources found on the host computers to create a "virtual-serial" connection 
  21. between the remotely connected computers.  
  22.  
  23. This program was written on the Amiga using the ACE Basic Compiler by David 
  24. Benn.  It has been tested successfully on an Amiga 500 running Kickstart 1.3 
  25. and an Amiga 4000/040.  If you do not have the narrator device and the 
  26. translator library, you will need to obtain them or change a line in the 
  27. stratego.prefs file (see later section).
  28.  
  29. Serial Stratego is now shareware.  If you like the program, please send $5 US 
  30. to register.  See the end of the document for my address.
  31.  
  32.  
  33.  
  34. II. THE RULES OF STRATEGO (skip this if you know them)
  35.  
  36. Stratego is played on a 10*10 board by two players (red and blue).  In the 
  37. middle of the board, there are two "lakes" which occupy 4 squares each. The 
  38. playing pieces of stratego are designed so that their identities remain hidden 
  39. to the opponent (the pieces stand up on the board, and each piece is labelled 
  40. on one side only). Each player begins with 40 playing pieces, and players 
  41. alternate turns, moving one piece into a new square each turn.  If a piece is 
  42. moved into a square that is occupied by one of the opponent's pieces, then 
  43. this is called a strike, and one of the two pieces will be removed from the 
  44. board (according to certain rules).  The object of the game is to capture the 
  45. flag of your opponent, which is one of his pieces.
  46.  
  47. There are 12 different kinds of playing pieces:
  48.  
  49.      Symbol:   Name:          Quantity:
  50.  
  51.      1         Marshall       1
  52.      2         General        1
  53.      3         Colonel        2
  54.      4         Major          3
  55.      5         Captain        4
  56.      6         Lieutenant     4
  57.      7         Sergeant       4
  58.      8         Miner          5
  59.      9         Scouts         8
  60.      S         Spy            1
  61.      *         Bomb           6
  62.      F         Flag           1
  63.  
  64. The pieces are numbered according to their power, the lowest numbers being the 
  65. most powerful.
  66.  
  67. Before the game begins, each player arranges his pieces on his side of the 
  68. board.  All of his pieces must be placed within the four rows closest to his 
  69. side of the board.  For example:
  70.  
  71.  
  72.           BBBBBBBBBB
  73.           BBBBBBBBBB      "B" - Blue Playing Pieces
  74.           BBBBBBBBBB      "R" - Red Playing Pieces
  75.           BBBBBBBBBB      "*" - Empty Squares
  76.           **  **  **      " " - Lake
  77.           **  **  **
  78.           RRRRRRRRRR
  79.           RRRRRRRRRR
  80.           RRRRRRRRRR
  81.           RRRRRRRRRR
  82.  
  83.  
  84. As soon as both players have finished setting up their pieces, the game 
  85. begins.  At this point, neither player knows the identity of any of his 
  86. opponent's pieces.  The red player takes the first turn.
  87.  
  88. All pieces are movable except for the bombs and the flag.  During his turn, a 
  89. player moves one of his movable pieces to an adjacent square (but not 
  90. diagonally).  The Scout (9) is special, and can be moved across any number of 
  91. unoccupied squares (horizontally or vertically).  According to the original 
  92. rules, the scout may not move across multiple squares and strike a piece 
  93. during the same turn, however in this implementation a provision has been made 
  94. so that this rule may be changed.  If this option is selected, then a scout 
  95. may move and strike in the same turn.
  96.  
  97. When a piece strikes an opponent's piece, the identities of both pieces are 
  98. revealed.  The winner is determined by the ranks of the two pieces.  In 
  99. general, a piece may defeat any other piece of a higher number (with one 
  100. exception), and if one piece strikes another piece of the same rank then both 
  101. pieces are lost.  A two will defeat a three or four but not a one, for 
  102. example.  The only exception to this hierarchy is the spy.  Any piece may 
  103. strike the spy and defeat it, but if the spy strikes a Marshall (1), then the 
  104. spy will prevail.  Bombs defeat all pieces except the miner (8).  When the 
  105. attacking piece wins the strike, it is moved into the square occupied by the 
  106. defending piece.  When the defending piece wins the strike, it is moved into 
  107. the square occupied by the attacking piece.  In this implementation, there is 
  108. an option to allow the defending piece to remain in its square when it wins a 
  109. strike (another popular way to play the game).
  110.  
  111. The game is won when one player strikes his opponent's flag or removes all of 
  112. his opponent's pieces.  If a player is unable to move a piece, then he loses.
  113.  
  114.  
  115.  
  116.  
  117. III. USING THE PROGRAM
  118.  
  119. The program may be started from Workbench or the Shell.  If the program does 
  120. not load, make sure that the serial port is not being used by another program.  
  121. Run the program from the Shell to see any error messages.
  122.  
  123. Once loaded, the program will begin a simple terminal program to facilitate 
  124. making a serial connection.  While in terminal mode, there are 10 user 
  125. programmable macros that can be accessed through the Macros menu.  These are 
  126. stored one macro per line in a file called "stratego.macros".  The macros can 
  127. be useful in dialing phone numbers, logging on to a computer, or other tasks.  
  128. Once the connection is made, you should talk to the other player and decide 
  129. which sides you will be playing.  Then select your color from the Setup menu 
  130. to begin playing the game.  Here are some examples of different ways Serial 
  131. Stratego may be used:
  132.  
  133. Modem-
  134. Use the terminal program to manually dial another computer.  Have the other 
  135. computer answer.  Verify the connection and then start the game from the Setup 
  136. menu.
  137.  
  138. Null Modem-
  139. Connect two computers with a null modem cable, verify that the connection is 
  140. functioning, and then start the game from the Setup menu.  It may be necessary 
  141. to change your system's serial preferences to "no handshaking" when using a 
  142. null modem connection.
  143.  
  144. Remote login and Talk/Write/IRC-
  145. Use the terminal program to dial a computer on Internet.  Establish a talk 
  146. session with another user, or have both players use the write command to talk 
  147. to each other.  Once the connection has been verified, start the game from the 
  148. Setup menu.  It is also possible to use this program with IRC.  Just begin 
  149. using IRC on the remote computer, join a channel with the other player, and 
  150. then press ESCAPE.  It is desirable to use the "-d" switch when invoking the 
  151. IRC client since this will eliminate the screen control characters, but 
  152. stratego will function properly without the "-d" switch.  IRC usage may be 
  153. unreliable at times due to netsplits.  The raw serial communications can 
  154. always be monitored by switching screens to the terminal emulator.
  155.  
  156. As soon as your color has been selected from the Setup menu, a new screen will 
  157. appear with two windows.  One window will contain the board and the other will 
  158. be used for text, messages, and information.
  159.  
  160. When the board is first displayed, the pieces will be arranged in groups 
  161. according to their rank.  Before play begins, the pieces must be set up.  The 
  162. pieces are arranged by exchanging the locations of pieces.  To select a 
  163. particular piece, just move the pointer onto it and click the left mouse 
  164. button.  Then do the same thing for the piece that you want to exchange 
  165. positions with.  When you have set the board up and are ready to continue 
  166. playing, select "Done Setting Up" from the Setup menu.
  167.  
  168. The Setup menu also allows you to load or save up to five different board 
  169. setups.  These boards may be created and saved during the game setup so that 
  170. you can store your favorite configurations for use in later games.  Once a 
  171. setup is loaded, you can still re-arrange pieces on the board.  You may also 
  172. save the board in the middle of a game in the event that the connection is 
  173. lost.  To resume playing, restart and load the saved board.  If a board is 
  174. saved after the game has begun, it cannot be modified during the game setup 
  175. when it is loaded again.
  176.  
  177. When you have finished setting up, your opponent will be notified.  When the 
  178. second player is done setting up, the game will begin.  Players take turns 
  179. moving their pieces.  To move a piece, click on the piece and then on the 
  180. square to which you want to move it.  If you decide not to move the piece, 
  181. click on it again to unselect it.  If it is impossible to move any of your 
  182. pieces, if you have run out of pieces to move, or if you would like to concede 
  183. the game, you may select "Concede Game" from the game menu.  Otherwise, the 
  184. game will be finished when a player strikes his opponent's flag.  When your 
  185. opponent moves his pieces, a "+" symbol will be placed on the last piece that 
  186. he moved.  This is done in case a move is made while you are not watching the 
  187. screen.
  188.  
  189. When the game is completed, both players will be notified.  If a player wishes 
  190. to reveal the locations of his remaining pieces to his opponent, he may do so 
  191. by selecting "Reveal Pieces" from the game menu.  At this point, a new game 
  192. may be started or you may return to the terminal emulator using the game menu.   
  193.  
  194. At any time during the setup, gameplay, or after the game,  you may send 
  195. messages to your opponent.  Just begin typing a message from the keyboard.  
  196. When you press return, the message will be sent to your opponent.  All 
  197. messages are printed and spoken using the Amiga's SPEAK: device.  The last 13 
  198. messages that you send are logged, and you can resend them quickly by 
  199. selecting them under the dialog menu.  Message logging may be turned off and 
  200. on using the "Message Buffer is Off/On" menu selections under the dialog menu.  
  201. This permits you to record certain messages which you may want to send 
  202. frequently and have them easily available via a menu selection.
  203.  
  204. The "Rank Report" selection under the game menu displays the number of pieces 
  205. of each type that you have captured.  This is useful in determining which 
  206. pieces your opponent has left.
  207.  
  208. There are two variations of the stratego rules that may be played.  These are 
  209. controlled by the "Scout Strike" and "Defender Occupies" selections in the 
  210. game menu.  These options may be changed by the red player only.  Normally, a 
  211. player may move his scout across many unoccupied squares, but may not strike 
  212. in the same turn unless it is to an adjacent square.  When the "Scout Strike" 
  213. option in the game menu is enabled, both players may move and strike across 
  214. multiple unoccupied squares with a scout during a single turn.  The other 
  215. option that may be changed concerns the placement of the piece that is being 
  216. attacked in a strike.  If  the piece that is being struck wins, then that 
  217. piece is moved into the square that was occupied by the attacking piece.  If 
  218. the "Defender Occupies" mode is turned off, then the attacked piece will 
  219. remain in its original square if it defeats the attacker.
  220.  
  221. The "Send Ping" menu selection is useful to determine if both programs are 
  222. sending and receiving packets.  When selected, you should send a "Ping..." and 
  223. receive a "Pong" slightly later.  Both of these events should be displayed in 
  224. the text window.  If no "Pong" is received, then there is something wrong with 
  225. the connection.  Wait and send some more "Pings".  If the connection becomes 
  226. re-established, then the "Sanity Check" feature should be used to 
  227. re-synchronize the packet counters on both computers.  If "Ping" is still 
  228. having problems, then return to terminal mode.  The ping function should 
  229. normally be used to verify that the other player is still there if you haven't 
  230. heard from him (maybe his computer crashed, or the modem was disconnected, 
  231. etc.).
  232.  
  233. Another diagnostic is the "Sanity Check" under the game menu.  This has two 
  234. functions. It checks to make sure that the pieces are arranged in the same way 
  235. on both boards (this may not be the case if some packets were completely lost 
  236. during the game because of bad line noise or other circumstances).  The 
  237. "Sanity Check" will report a fatal error if the boards do not match.  The 
  238. second feature of the sanity check function is the synchronization of packet 
  239. counters on both computers.  Each computer keeps track of how many messages 
  240. have been sent by the other, so that if there is an error, a re-send may be 
  241. requested.  If a packet is completely lost and undetected for some reason, 
  242. then these numbers will be inconsistent.  The sanity check will check for an 
  243. inconsistency in the packet counters and automatically correct it ("Sync 
  244. Error" will be displayed).
  245.  
  246.  
  247.  
  248.  
  249. IV.  THE PREFERENCES FILE
  250.  
  251. The file "stratego.prefs" contains a few parameters that may be modified to 
  252. suit your needs.  The following is a listing of the standard preferences file:
  253.  
  254. -------------------- Begin file after this line.
  255. 19200
  256. N81SF
  257. serial.device
  258. +++
  259. ath
  260. 0
  261. SPEAK:
  262. $%&'
  263. 0
  264. -------------------- File ends with previous line.
  265.  
  266.  
  267. Here is a detailed description of the elements of the preferences file:
  268.  
  269. Line #:    Description:
  270.  
  271. 1             The baud rate of your serial connection.
  272.  
  273. 2             The ACE parameters for opening the serial device:
  274.  
  275.     N/E/O Parity none, even, odd
  276.     8/7 bits per word
  277.     0/1 stop bit
  278.     3 - 3 wire handshaking (optional)
  279.     S - Shared access to serial device (optional)
  280.     F - Fast serial mode (optional)
  281.  
  282. 3         The name of the serial device.  Maybe you would like to use the AUW 
  283. device or a faster serial device instead.  Just put the name of the device 
  284. that you want to use here.
  285.  
  286. 4         The unit number of the serial device.
  287.  
  288. 5         The command mode sequence for your modem (this should not need to be 
  289. changed).
  290.  
  291. 6         The hangup command for your modem (this should not need to be 
  292. changed).
  293.  
  294. 7         The name of  the device/file that you want spoken text to be 
  295. directed to.  If you don't have the speak device with your version of 
  296. AmigaDOS, get it from someone or direct this to NIL: or another device 
  297. instead.  You can also change the sound of voice by adding parameters to the 
  298. end of the device name (see AmigaDOS manuals).
  299.  
  300. 8         The four characters that are used to mark the beginning and ending 
  301. of packets sent by both players.  This line MUST be the same for both players.  
  302. this should only be changed when the characters that are being used might 
  303. interfere with the connection in some way (see technical notes).
  304.  
  305. 9         Miscellaneous flags.  Currently this may have the following values:
  306.  
  307.         0 --> Default
  308.         1 --> Poll the keyboard frequently (improves keyboard performance on 
  309. slower machines)
  310.         2 --> Don't load or use sounds (conserve CHIP memory)
  311.         3 --> Poll keyboard frequently and don't use sounds.
  312.  
  313.  
  314. V. TECHNICAL NOTES (how the packet subroutines work)
  315.  
  316. I have always found it neat that you can talk to people on other networked 
  317. computers around the world for free.  The "talk" program on most UNIX machines 
  318. allows you to call up another person on a different computer connected to the 
  319. network.  You can then carry on a conversation by typing text, character by 
  320. character, to the other person's screen.  The "write" program lets you type 
  321. and send sentences of text to another person's screen (provided that they are 
  322. logged on to the same computer).  When two people "write" to each other, they 
  323. can carry on a conversation by taking turns sending lines of text and pressing 
  324. return after each line.  Internet Relay Chat lets groups of people on 
  325. different computers talk and send messages to each other on different 
  326. channels.
  327.  
  328. I am also interested in multiplayer computer games.  The only problems with 
  329. modem or null-modem type games are that it costs money to play games over long 
  330. distances and it is difficult to find ways to connect more than two players 
  331. using modems.  
  332.  
  333. This gave me the idea to develop some subroutines which would encode strings 
  334. into packets which could be sent as normal text and thus be transmitted 
  335. through the network via programs that were intended to be used for 
  336. communicating text in real-time.  One subroutine would take as input a 
  337. character string, encode it, and send it.  The other routine would monitor the 
  338. serial device, decode packets, and return them to the program.  In many ways 
  339. this is similar to network layers which provide an "invisible" channel through 
  340. which to communicate.  My subroutines convert these network resources into 
  341. "virtual-serial" connections between two remotely connected computers.
  342.  
  343. I wanted the subroutines to be as generally useful as possible, so I decided 
  344. to use only standard ASCII printable characters to encode the packets.  This 
  345. implementation uses characters 63-126 and 36-39.  Characters 63-126 are used 
  346. to send data, and 36-39 are used to mark the beginnings and endings of 
  347. packets.  In order to prevent interference between messages that are sent and 
  348. echoed back (the remote computer sends back everything that you type so you 
  349. can see it), and what the other player sends you, I divided the usable 
  350. characters into two portions- one for each player.  The packet send routine 
  351. uses only the characters allowed for that player and includes a CR (carriage 
  352. return) at the end of each packet ("write" requires a CR before a sentence is 
  353. sent to the other terminal).  The packet receive routine filters out all 
  354. characters except those of the kind sent by the other player.  In addition, it 
  355. filters out ALL characters that are not found between a packet begin and 
  356. packet end character.  This means that anything not contained inside the 
  357. packet delimiters will be filtered out and ignored.  In addition, VT-100 
  358. screen escape sequences are filtered from input inside of each packet.  The 
  359. four characters that are used to define a packet begin, and end, for both 
  360. players may be changed if they interfere with the communication method.  These 
  361. characters are located in the preferences file, but should be changed with the 
  362. understanding that both players must have the same string on this line in 
  363. their preferences file or the programs will not communicate.
  364.  
  365. A CRC-16 checksum is used for error detection, and a data timeout is detected 
  366. when a certain amount of time elapses after a packet begin is received, but no 
  367. packet end is received.  If an error is detected, a resend can be requested.  
  368. The previous 10 packets sent (including resends and resend requests) are 
  369. buffered so that if extreme durations of line noise occur, all packets can be 
  370. eventually recovered.  All errors and resends are displayed in the text 
  371. window, notifying the players.
  372.  
  373. If anyone is interested in writing more multiplayer games in ACE, I would be 
  374. more than happy to donate these subroutines and assist in their implementation 
  375. into a program.
  376.  
  377.  
  378.  
  379.  
  380. VII. MISCELLANEOUS INFORMATION
  381.  
  382. If you like this program, please send $5 US to:
  383.  
  384. Daniel Oberlin
  385. 3A Gaslight Village
  386. Ithaca NY, 14850
  387.  
  388. I would appreciate hearing from anyone who has suggestions, bug reports, or an 
  389. interest in playing stratego with this program.  In fact, please send me 
  390. E-mail just letting me know that you have tried my program and under what 
  391. circumstances.  If you have an interest in using the packet sending/receiving 
  392. subroutines to write other games with ACE, I would be happy to provide the 
  393. source code.  Here is how I can be reached (start with the top E-mail address, 
  394. the others are longer term but checked less frequently):
  395.  
  396. fkrj@crux2.cit.cornell.edu
  397. oberlin@chemres.tn.cornell.edu
  398. doberlin@math.fsu.edu
  399.  
  400. IRC Nicks: obi1, DogMaps.  Generally found on channel #amiga.
  401.  
  402.  
  403. Program History:
  404. Version 1.0 - 
  405.     first beta test version.
  406.  
  407. Version 1.2 -
  408.     contains many added features and enhancements.
  409.  
  410. Version 1.3 -
  411.     first public release.
  412.  
  413. Version 1.4 -
  414.     beta release of version 1.5
  415.  
  416. Version 1.5 -
  417.     Not compatible with previous versions!
  418.     Messages may now be initiated by simply typing from the keyboard.
  419.     User definable menu macros are added to the terminal emulator.
  420.     Menu performance is improved.
  421.     Messages are limited in size preventing an overflow.
  422.     Boards can be saved in mid game and recovered.
  423.     Sound effects are added.
  424.     Data error checking now uses CRC-16.
  425.     Code has been cleaned up somewhat.
  426.  
  427. Future plans:
  428. A title page.  If people show enough interest, I might  add AmiTCP support as 
  429. well.  
  430.  
  431.  
  432. Acknowledgments:
  433.  
  434. David Benn-
  435. for writing the ACE compiler used to compile this program.  I really like ACE 
  436. a lot and hope that it will be developed further.
  437.  
  438. My brother Richard-
  439. who patiently tested the program with me.
  440.  
  441. Amiga-
  442. the best microcomputer platform.
  443.  
  444.